package cn.lintcode;


/**
 * @author labvi
 * @version 1.0.0
 */
public class TreeMaxHeight {
    static class TreeNode {
        public int val;
        public TreeNode left, right;

        public TreeNode(int val) {
            this.val = val;
            this.left = this.right = null;
        }
    }

    public int maxDepth(TreeNode root) {
        // write your code here
        return getHeight(root);
    }

    public int getHeight(TreeNode root){
        if (root == null){
            return 0;
        }
        int l = getHeight(root.left);
        int r = getHeight(root.right);
        return Math.max(l,r)+1;
    }
}
